def login():
    while 1:
        choice = input("请输入选项：1.登录 2.退出系统:")
        if choice == "1":
            username = input("请输入账号:")
            password = input("请输入密码:")
            print("登录成功")
            budget = input("请输入预算:")
            goods0 = input("请输入商品编号:")
            goods(goods0)
            add = input("是否将该商品加入购物车？(输入3加入):")
            if add == 3:
               ShoppingCart(goods0)

            break
        elif choice == "2":
            print("已退出")
            break
        else:
            print("输入不合法请重新输入")

products = {
    '001': {'name': 'apple', 'price': 15},
    '002': {'name': 'banana', 'price': 9},
    '003': {'name': 'origin', 'price': 8},
    '004': {'name': 'pear', 'price': 11},
    '005': {'name': 'peach', 'price': 13}
}

def goods(product_id):
    if product_id in products:
        product = products[product_id]
        print(f"商品名：{product['name']}  "f"价格：{product['price']}")
    else:
        print(f"没有找到编号为{product_id}的商品")


def ShoppingCart(x):
    list1 = []
    if x in products:
        list1.append(products[x])
        print(list1)
login()





